package com.aplink.generic.pojo.googlemaps;

import java.lang.reflect.Type;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;

public class Distance implements JsonDeserializer<Distance> {
	private String mText;
	private int mValue;

	@Override
	public Distance deserialize(JsonElement element, Type type,
	        JsonDeserializationContext context) throws JsonParseException {
		JsonObject jsonObject = element.getAsJsonObject();
		mText = jsonObject.get("text").getAsString();
		mValue = jsonObject.get("value").getAsInt();
		return this;
	}

	/**
	 * text contains a string representation of the distance, which by default
	 * is displayed in units as used at the origin
	 *
	 * @return
	 */
	public String getText() {
		return mText;
	}

	/**
	 * value indicates the distance in meters
	 *
	 * @return
	 */
	public int getValue() {
		return mValue;
	}

	public void setText(String text) {
		mText = text;
	}

	public void setValue(int value) {
		mValue = value;
	}

}
